#ifndef ISNW_RECT_CPP
#define ISNW_RECT_CPP

#include "ISNW_Rect.h"
using namespace ISNW;

template<typename Type>
RECT ISNW_Rect<Type>::Rect()
{
	RECT r;
	r.left = cast(LONG,m_left);
	r.right = cast(LONG,m_right);
	r.top = cast(LONG,m_top);
	r.bottom = cast(LONG,m_bottom);
	return r;
}

template<typename Type>
ISNW_BOOL ISNW_Rect<Type>::IsPointIn(const ISNW_Point<Type>& p)
{
	if(p.x() > m_left && p.x() < m_right && p.y() > m_top && p.y() < m_bottom){
		return ISNW_TRUE;
	}else{
		return IsNW_FALSE;
	}
}

template<typename Type>
ISNW_Rect<Type> ISNW_Rect<Type>::Union(const ISNW_Rect<Type>& r)
{
	Type l = ISNW_Max(m_left,r.m_left);
	Type r = ISNW_Min(m_right,r.m_right);
	Type t = ISNW_Max(m_top,r.m_top);
	Type b = ISNW_Min(m_bottom,r.m_bottom);

	ISNW_Rect<Type> r;
	if(l <= r && t <= b){
		r.Set(l,r,t,b);
	}
	return r;
}

#endif